from appuifw import app
from e32 import drive_list,start_exe
from os import path as ospath
from codecs import open as codecopenfile
from struct import unpack
from msys import send_bg as switch_to_bg

switch_to_bg()
__appname__=u'NetAlarm'
nomeeseguibileserver = 'netalarm_server_0xeaea0000.exe'
settingsfile=u'c:\\data\\others\\%s.cfg'% __appname__.lower()
numerotacche=1
numerointervallo=30
autostart=0

if ospath.exists(settingsfile):
	try:
		readsettings=codecopenfile(settingsfile,'rb').readlines()[0]
		try: numerotacche,numerointervallo,autostart=unpack('>hhh',readsettings)
		except: pass
	except: pass

if autostart:
	#drives=drive_list()
	#percorso=u'\\sys\\bin\\%s'%(nomeeseguibileserver)
	#for d in drives:
		#try: start_exe(u'%s%s'%(d,percorso),'')
		#except: continue
	try: start_exe(unicode(nomeeseguibileserver),'')
	except: pass

app.set_exit()